package one.two.eighteen;

public class AccumulatorOriginal {

	private double m;
	private double s;
	private int N;

	public void addDataValue(double x) {
		N++;
		m = m + (x - m) / N;
		s = s + 1.0 / N * (x - m) * (x - m);
	}

	public double mean() {
		return m;
	}

	public double var() {
		return s;
	}

	public double stddev() {
		return Math.sqrt(this.var());
	}

}
